package net.zjitc.servlet.second;

import net.zjitc.service.SecondService;
import net.zjitc.service.impl.SecondServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 2 * @Author: 洪瑶
 * 3 * @Date: 2018/10/30 11:37
 * 4
 */
@WebServlet(name = "DServlet",urlPatterns = "/dServlet")
public class DServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        SecondService service = new SecondServiceImpl();
        String cid = request.getParameter("csid");
        int id = Integer.parseInt(cid);
        try {
            service.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        request.getRequestDispatcher("/findAllServlet").forward(request,response);

    }
}
